// Author: Domien Nowicki

#ifndef SINGLEGAME_H
#define SINGLEGAME_H

#include "Game.h"
#include "Map.h"
#include "Player.h"
#include "Clock.h"
#include "Highscore.h"

class SingleGame: public Game
{
public:

	// Constructors
	SingleGame(const Map& map, const Properties& properties, Highscore& highscore);

	// Destructor
	virtual ~SingleGame();

	// Overloaded operations a game can do
	virtual void Start();
	virtual void Stop();

	// Help for the player
	virtual void Hint();
	virtual void ColorMap();


protected:
	enum ColorMapMethod { COLORCONTINUE, COLORABORT, COLORALL };
	static const int RESTRICTIONABORT = -1;
	// Operations on showing or getting information from user
	virtual bool GetName(std::string *name) = 0;
	virtual int GetNumber(int min, int max) = 0;
	virtual void ShowHighscore(const Highscore& highscore) = 0;
	virtual ColorMapMethod ShowMove(const Move& move) = 0;

	// Overloaded new components allocation
	virtual Player* NewHumanPlayer(Map* map) = 0;
	virtual Map* NewMap(const Map& map) = 0;
	virtual Clock* NewClock(Clock::ClockType type) = 0;

	// Operation when game has ended
	virtual void EndGame(const Player *player);
	// Get running time for this game
	int GetTime() const;

	// The human player interface
	Player* humanPlayer;

private:
	// Helper functions
	void Clear();
	const Highscore& GetHighscore();
	bool GetColorMapRestriction(int *colorCount);


	const Map* map;
	Map* humanMap;
	Clock *clock;
	Highscore *highscore;

	// Penalty for asking a hint
	static const int TIMEPENALTY = 30;

	// Minimum colors required to solve a map
	static const int MINCOLOR = 4;
};

#endif //SINGLEGAME_H